const express = require("express");
var bodyParser = require("body-parser");
const router = express.Router();
var urlencodedParser = bodyParser.urlencoded({ extended: false });
const Mock = require("mockjs");
router.post("/adminTable", (req, res) => {
  const data = Mock.mock({
    code: 200,
    data: {
      "dataSource|50": [
        {
          "id|+1": 1,
          name: " @cword(2,4)",
          userName: "@natural()",
          passWorld: '@string("upper", 10)',
          remarks: " @cword(2,4)",
        },
      ],
      total: 50,
      currentPage: 1,
      pageSize: 10,
    },
  });
  res.json(data);
});
router.post("/adminCreate", urlencodedParser, (req, res) => {
  const { id } = req.body;
  const data = id
    ? {
        code: 200,
        data: {
          message: "更新成功",
        },
      }
    : {
        code: 200,
        data: {
          message: "创建成功",
        },
      };
  res.json(data);
  });
  router.post("/editAdmin", urlencodedParser, (req, res) => {
    const data = Mock.mock({
        code: 200,
        data: {
          "dataSource|1": [
            {
              "id|+1": 1,
              name: " @cword(2,4)",
              userName: "@natural()",
              passWorld: '@string("upper", 10)',
              remarks: " @cword(2,4)",
            },
          ],
          total: 50,
          currentPage: 1,
          pageSize: 10,
        },
      });
    res.json(data);
  });
  router.post("/deladminTable", (req, res) => {
    const data = Mock.mock({
      code: 200,
      message: "success",
    });
    res.json(data);
  });
module.exports = router;
